home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / sysdeps / alpha / udiv_qrnnd.S < prev   
Text File  |  1994-04-26  |  3KB  |  153 lines

  1.  # Alpha 21064 __udiv_qrnnd
  2.  
  3.  # Copyright (C) 1992, 1994 Free Software Foundation, Inc.
  4.  
  5.  # This file is part of the GNU MP Library.
  6.  
  7.  # The GNU MP Library is free software; you can redistribute it and/or modify
  8.  # it under the terms of the GNU Library General Public License as published by
  9.  # the Free Software Foundation; either version 2 of the License, or (at your
  10.  # option) any later version.
  11.  
  12.  # The GNU MP Library is distributed in the hope that it will be useful, but
  13.  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  14.  # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
  15.  # License for more details.
  16.  
  17.  # You should have received a copy of the GNU Library General Public License
  18.  # along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
  19.  # the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  
  22.         .set noreorder
  23.         .set noat
  24.  
  25. .text
  26.         .align 3
  27.         .globl __udiv_qrnnd
  28.         .ent __udiv_qrnnd 0
  29. __udiv_qrnnd:
  30. __udiv_qrnnd..ng:
  31.         .frame $30,0,$26,0
  32.         .prologue 0
  33. #define cnt    $2
  34. #define tmp    $3
  35. #define rem_ptr    $16
  36. #define n1    $17
  37. #define n0    $18
  38. #define d    $19
  39. #define qb    $20
  40.  
  41.     ldiq    cnt,16
  42.     blt    d,Largedivisor
  43.  
  44. Loop1:    cmplt    n0,0,tmp
  45.     addq    n1,n1,n1
  46.     bis    n1,tmp,n1
  47.     addq    n0,n0,n0
  48.     cmpule    d,n1,qb
  49.     subq    n1,d,tmp
  50.     cmovne    qb,tmp,n1
  51.     bis    n0,qb,n0
  52.     cmplt    n0,0,tmp
  53.     addq    n1,n1,n1
  54.     bis    n1,tmp,n1
  55.     addq    n0,n0,n0
  56.     cmpule    d,n1,qb
  57.     subq    n1,d,tmp
  58.     cmovne    qb,tmp,n1
  59.     bis    n0,qb,n0
  60.     cmplt    n0,0,tmp
  61.     addq    n1,n1,n1
  62.     bis    n1,tmp,n1
  63.     addq    n0,n0,n0
  64.     cmpule    d,n1,qb
  65.     subq    n1,d,tmp
  66.     cmovne    qb,tmp,n1
  67.     bis    n0,qb,n0
  68.     cmplt    n0,0,tmp
  69.     addq    n1,n1,n1
  70.     bis    n1,tmp,n1
  71.     addq    n0,n0,n0
  72.     cmpule    d,n1,qb
  73.     subq    n1,d,tmp
  74.     cmovne    qb,tmp,n1
  75.     bis    n0,qb,n0
  76.     subq    cnt,1,cnt
  77.     bgt    cnt,Loop1
  78.     stq    n1,0(rem_ptr)
  79.     bis    $31,n0,$0
  80.     ret    $31,($26),1
  81.  
  82. Largedivisor:
  83.     and    n0,1,$4
  84.  
  85.     srl    n0,1,n0
  86.     sll    n1,63,tmp
  87.     or    tmp,n0,n0
  88.     srl    n1,1,n1
  89.  
  90.     and    d,1,$6
  91.     srl    d,1,$5
  92.     addq    $5,$6,$5
  93.  
  94. Loop2:    cmplt    n0,0,tmp
  95.     addq    n1,n1,n1
  96.     bis    n1,tmp,n1
  97.     addq    n0,n0,n0
  98.     cmpule    $5,n1,qb
  99.     subq    n1,$5,tmp
  100.     cmovne    qb,tmp,n1
  101.     bis    n0,qb,n0
  102.     cmplt    n0,0,tmp
  103.     addq    n1,n1,n1
  104.     bis    n1,tmp,n1
  105.     addq    n0,n0,n0
  106.     cmpule    $5,n1,qb
  107.     subq    n1,$5,tmp
  108.     cmovne    qb,tmp,n1
  109.     bis    n0,qb,n0
  110.     cmplt    n0,0,tmp
  111.     addq    n1,n1,n1
  112.     bis    n1,tmp,n1
  113.     addq    n0,n0,n0
  114.     cmpule    $5,n1,qb
  115.     subq    n1,$5,tmp
  116.     cmovne    qb,tmp,n1
  117.     bis    n0,qb,n0
  118.     cmplt    n0,0,tmp
  119.     addq    n1,n1,n1
  120.     bis    n1,tmp,n1
  121.     addq    n0,n0,n0
  122.     cmpule    $5,n1,qb
  123.     subq    n1,$5,tmp
  124.     cmovne    qb,tmp,n1
  125.     bis    n0,qb,n0
  126.     subq    cnt,1,cnt
  127.     bgt    cnt,Loop2
  128.  
  129.     addq    n1,n1,n1
  130.     addq    $4,n1,n1
  131.     bne    $6,Odd
  132.     stq    n1,0(rem_ptr)
  133.     bis    $31,n0,$0
  134.     ret    $31,($26),1
  135.  
  136. Odd:
  137.     ! q' in n0. r' in n1
  138.     addq    n1,n0,n1
  139.     cmpult    n1,n0,tmp    # tmp := carry from addq
  140.     beq    tmp,LLp6
  141.     addq    n0,1,n0
  142.     subq    n1,d,n1
  143. LLp6:    cmpult    n1,d,tmp
  144.     bne    tmp,LLp7
  145.     addq    n0,1,n0
  146.     subq    n1,d,n1
  147. LLp7:
  148.     stq    n1,0(rem_ptr)
  149.     bis    $31,n0,$0
  150.     ret    $31,($26),1
  151.  
  152.     .end    __udiv_qrnnd
  153.